/**
 * @param {Array} value
 * @returns {Boolean}
 */
export default function checkPermission(value) {
  if (value && value instanceof Array && value.length > 0) {
    if (localStorage.getItem('roles')) {
      const roles = JSON.parse(localStorage.getItem('roles'))
      const permissionRoles = value

      const hasPermission = roles.some(role => {
        return permissionRoles.includes(role)
      })

      if (!hasPermission) {
        return false
      }
      return true
    }
  } else {
    return false
  }
}
